package com.feidee.data.report.init;

import com.feidee.data.report.constant.Constant;
import com.feidee.data.report.dao.IReportAndSourceStatusDao;
import com.feidee.fdcommon.configuration.CustomConfiguration;
import org.apache.log4j.Logger;

/**
 * 初始化报表运行状态
 */
public class InitReportRunStatus {

	private IReportAndSourceStatusDao reportAndSourceStatusDao;

	private Logger logger = Logger.getLogger(InitReportRunStatus.class);

	/**
	 * 初始化报表运行状态,将等待运行状态和正在运行状态改为未执行状态
	 */
	public void init() {

		Constant.EXECUTE_REPORT_THREAD_SLEEP_TIME = CustomConfiguration.getLong("thread.sleep.time", 180000);
		Constant.REPORT_WAIT_MAX_TIME = CustomConfiguration.getLong("report.wait.maxtime", 14400000);
		logger.info("************ 初始化依赖报表相关参数 线程睡眠时间:" + Constant.EXECUTE_REPORT_THREAD_SLEEP_TIME
				+ " 报表执行等待依赖报表最大时间:" + Constant.REPORT_WAIT_MAX_TIME);

		logger.info("************ 初始化各报表执行状态,清除等待执行和正在执行状态，改为未执行状态 *************");
		int res = reportAndSourceStatusDao.clearReportDdzxAndZzzxRunStatus();
		if (0 == res) {
			logger.info("************************** 初始化各报表执行状态成功 *********************************");
		} else {
			logger.info("************************** 初始化各报表执行状态失败 *********************************");
		}
	}

	public IReportAndSourceStatusDao getReportAndSourceStatusDao() {
		return reportAndSourceStatusDao;
	}

	public void setReportAndSourceStatusDao(IReportAndSourceStatusDao reportAndSourceStatusDao) {
		this.reportAndSourceStatusDao = reportAndSourceStatusDao;
	}
}
